<jsp:useBean id="register" class="dasregistry.registryBean"	scope="page" />
<jsp:useBean id="organism" class="dasregistry.OrganismBean" scope="session" />


<jsp:directive.page import="java.util.Comparator" />

<%@ page import="org.biojava.services.das.dao.Role" %>
<%@ page import="org.biojava.services.das.dao.RegistryUser" %>
<%@ page import="org.biojava.services.das.registry.UserManager" %>

<%@ include file="logincheck.jsp"%>



<% 
	

	String title="Create new Organism";
 	String header= title;



%>

<%@ include file="pagehead.jsp" %>    
<script language = "javascript" src="javascripts/alphabetLimitedDropdown.js">
/** 
* The findOption() searches the drop-down list by reading the text in the option tag 
* It searches the list with oner and / or two characters. 
*/ 
function findOption(selects, evt) { 
	if (window.event) var k = String.fromCharCode(event.keyCode); 
		else var k = String.fromCharCode(evt.which); 
	if (k < " " || k > "~") return true; 
	if (k == " ") { fnd = ""; } else fnd += k.toUpperCase(); 

	
	if (fnd.length==2) searchOptions();
	window.clearTimeout(tmr);
	tmr = window.setTimeout("searchOptions()",1000);
	return (fnd.length==1);
}

function searchOptions() {
	window.clearTimeout(tmr);
	if (fnd.length>1) {
		for (var i = 0; i < selbx.options.length; i++) { 
			var optText = selbx.options[i].text.toUpperCase(); 
			//alert(i + ". option= " + optText + " searching= " + fnd); 
			if (optText.substr(0, fnd.length) == fnd) { 
				selbx.selectedIndex = i; 
				if (fnd.length == 2) fnd = ""; 
				return false; 
			}
		}
	}
	fnd = "";
}
      
    </script>



</head>
<body>
<%@ include file="pagebodystart.jsp" %>

<div id="main">

<% if (! isAdmin) 
{ 
%>
You are not logged in as administrator. Only administrators can create
new coordinate systems.
<a href="login.jsp">login</a>
.

<% 
   } 
   else { 

%>





<h2>Already known organsims</h2>

<p><%@ include file="sangertablestart.jsp"%>
<jsp:include  page="sangertablestart.jsp"/>

	<tr>
	

		<td>
		
		
		
      <input id="textInput" type = "text" value = "" 
        onkeyup="getData('textInput','organisms.jsp', 'targetDiv')"> 
    <br>
    <br>

    <div id="targetDiv">
      Type in the first 3 letters at least of the scientific name of an organism and a dropdown will appear here with the options already available in the registry. 
    </div> 
		
		
		
		</td>
	</tr>
<jsp:include  page="sangertableend.jsp"/>


<hr/>

<h2>Create a new Organism</h2>


<jsp:include  page="sangertablestart.jsp"/>

	<form method="post" action="createOrganismSysAction.jsp"
		name="create_form"><!-- name -->
	<tr class="row1">
		<td>1.</td>
		<td>What is the Scientific Name for this Organism?</td>
		<td><input type="input" name="scientificName" size="20"value="<%=organism.getScientificName() %>" /></td>
		<td>e.g. Homo sapiens
		</td>
	</tr>

	<tr class="row2">
		<td>&nbsp;</td>
		<td valign="top">What is the Taxonomy ID?</td>
		<td><input type="input" name="taxId" size="20"value="<%=organism.getTaxId() %>" /></td>
		<td>e.g. 9606</td>
	</tr>




	<!-- coord sys type -->

	<tr class="row2">
		<td>&nbsp;</td>
		<td valign="top">What is a common name for this organism?</td>
		<td><input type="input" name="commonName" size="20"value="<%=organism.getCommonName() %>" /></td>
		<td>e.g. Human</td>
	</tr>




	


	<tr>
		<td colspan="4" valign="top" align="right"><input type="submit"
			value="Create"></td>
	</tr>
<jsp:include  page="sangertableend.jsp"/>

</form>
<%@ include file="sangertableend.jsp"%>

</p>


<%
}
%>

</div>
<%@ include file="sangerfooter.jsp"%>